<?php
namespace App\Controller;
class AskController extends BaseController
{
    /**
     * 首页
     */
    public function index(){
        $model = D('App/Base');
        $page_title = C("TITLE");
        //热门疾病分类
        $hot_disease = $model->getDisease(array('class'=>array('eq',1),'hot'=>array('eq',1)));
        //权威专家顾问团
        $expertData = M('Doctor')->field('id,name,picture,other1')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('not in','1,2,3')))->order('orders desc,name_pinyin_index asc,id desc')->limit(12)->select();
        //常见问题分类
        $illnessData = M('Menu_1','BingQing_','DB_CONFIG1')->field('id,name,name2')->where('Display=0')->order('Id asc')->select();
        foreach ($illnessData as $key => $value) {
            $illnessData[$key]['info'] = M('Menu_2','BingQing_','DB_CONFIG1')->field('id,name,name2')->where("Display=0 and show_value Like '%|2|%' and Menu_1='".$value['id']."'")->order('Id asc')->limit(7)->select();
        }
        //月经权威专家
        $yuejingDoctor = M('Doctor')->field('id,name,picture,other1')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in','2,9,10,179')))->order('orders desc,name_pinyin_index asc,id desc')->select();
        //子宫疾病权威专家
        $zigongDoctor = M('Doctor')->field('id,name,picture,other1')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in','12,6,7,198')))->order('orders desc,name_pinyin_index asc,id desc')->select();
        //卵巢囊肿
        $luanchaoDoctor = M('Doctor')->field('id,name,picture,other1')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in','8,17,32,24')))->order('orders desc,name_pinyin_index asc,id desc')->select();
        //问题总数
        $count = M('zixun','DB_','DB_CONFIG1')->count();
        //热门咨询
        $hot_zixun = $model->get_ask(array('Recommend'=>array('eq',1)), 8, array('length'=>20));
        foreach ($hot_zixun as $key => $value) {
            if(!$value['question']){
                unset($hot_zixun[$key]);
            }
        }
        //已解决问题
        $ok_question = $model->get_ask(array('Publish'=>array('eq',1),'BingQing_Menu_1'=>array('not in','|,||'),'BingQing_Menu_2'=>array('not in','|,||')), 13);
        foreach ($ok_question as $key => $value) {
            $class_info = M('Menu_2','BingQing_','DB_CONFIG1')->field('id class_id,menu_1,name2')->where('id='.$value['bingqing_menu_2'])->find();
            if($class_info['name2'] == '其它'){
                $class_info['name2'] = M('Menu_1','BingQing_','DB_CONFIG1')->where('id='.$class_info['menu_1'])->getField('name2');
                $class_info['class_id'] = M('Menu_1','BingQing_','DB_CONFIG1')->where('id='.$class_info['menu_1'])->getField('id');
            }
            $ok_question[$key]['class_name'] = $class_info['name2'];
            $ok_question[$key]['class_id'] = $class_info['class_id'];
        }
        //视频-电话实录-文字实录
        $video_phone = $model->get_article(array('a.type'=>array('eq',3)),'',9,'',array('length'=>45));
        /**
         *妇科常见疾病   
         */
        //月经病
        $yuejing1 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('eq',1),'Hot'=>array('neq',1),'img'=>array('neq',''),'Title'=>array('neq',''),'BingQing_Menu_1'=>array('like','%|4|%'),'BingQing_Menu_2'=>array('not in','|,||')),1);
        $yuejing2 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('eq',1),'Hot'=>array('neq',1),'Title'=>array('neq',''),'BingQing_Menu_1'=>array('like','%|4|%'),'BingQing_Menu_2'=>array('not in','|,||')),3);
        $yuejing3 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('neq',1),'Hot'=>array('neq',1),'Title'=>array('neq',' '),'BingQing_Menu_1'=>array('like','%|4|%'),'BingQing_Menu_2'=>array('not in','|,||')),5);
        foreach ($yuejing3 as $key => $value) {
            $yuejing3[$key]['bingqing_name'] = M('Menu_2','BingQing_','DB_CONFIG1')->where('id='.$value['bingqing_menu_2'])->getField('name2');
        }
        //子宫疾病
        $zigong1 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('eq',1),'Hot'=>array('neq',1),'img'=>array('neq',''),'Title'=>array('neq',''),'BingQing_Menu_1'=>array('like','%|1|%'),'BingQing_Menu_2'=>array('not in','|,||')),1);
        $zigong2 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('eq',1),'Hot'=>array('neq',1),'Title'=>array('neq',''),'BingQing_Menu_1'=>array('like','%|1|%'),'BingQing_Menu_2'=>array('not in','|,||')),3);
        $zigong3 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('neq',1),'Hot'=>array('neq',1),'Title'=>array('neq',' '),'BingQing_Menu_1'=>array('like','%|1|%'),'BingQing_Menu_2'=>array('not in','|,||')),5);
        foreach ($zigong3 as $key => $value) {
            $zigong3[$key]['bingqing_name'] = M('Menu_2','BingQing_','DB_CONFIG1')->where('id='.$value['bingqing_menu_2'])->getField('name2');
        }
        //卵巢疾病
        $luanchao1 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('eq',1),'Hot'=>array('neq',1),'img'=>array('neq',''),'Title'=>array('neq',''),'BingQing_Menu_1'=>array('like','%|2|%'),'BingQing_Menu_2'=>array('not in','|,||')),1);
        $luanchao2 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('eq',1),'Hot'=>array('neq',1),'Title'=>array('neq',''),'BingQing_Menu_1'=>array('like','%|2|%'),'BingQing_Menu_2'=>array('not in','|,||')),3);
        $luanchao3 = $model->get_ask(array('Publish'=>array('eq',1),'centerid'=>array('exp','is null'),'Recommend'=>array('neq',1),'Hot'=>array('neq',1),'Title'=>array('neq',' '),'BingQing_Menu_1'=>array('like','%|2|%'),'BingQing_Menu_2'=>array('not in','|,||')),5);
        foreach ($luanchao3 as $key => $value) {
            $luanchao3[$key]['bingqing_name'] = M('Menu_2','BingQing_','DB_CONFIG1')->where('id='.$value['bingqing_menu_2'])->getField('name2');
        }

        $this->assign(array(
            'hot_disease'    => $hot_disease,
            'expertData'     => $expertData,
            'illnessData'    => $illnessData,
            'yuejingDoctor'  => $yuejingDoctor,
            'zigongDoctor'   => $zigongDoctor,
            'luanchaoDoctor' => $luanchaoDoctor,
            'count'          => $count,
            'hot_zixun'      => $hot_zixun,
            'ok_question'    => $ok_question,
            'video_phone'    => $video_phone,
            'yuejing1'       => $yuejing1,
            'yuejing2'       => $yuejing2,
            'yuejing3'       => $yuejing3,
            'zigong1'        => $zigong1,
            'zigong2'        => $zigong2,
            'zigong3'        => $zigong3,
            'luanchao1'      => $luanchao1,
            'luanchao2'      => $luanchao2,
            'luanchao3'      => $luanchao3,
            'friend_link'    => true,
        ));
        $this->setPageInfo("{$page_title['title']}", "{$page_title['keyword']}", "{$page_title['desc']}", 1);
        $this->display();
    }

    public function browse(){
        $model = D('App/Base');
        $id = I('get.id',0,'intval');
        $cat = $this->cat_list($id);
        //相关问题
        $count = M('zixun','DB_','DB_CONFIG1')->where("BingQing_Menu_2 LIKE '%|".$id."|%'")->count();
        $page = new \Tool\Page($count,30);
        // 配置翻页的样式
        $pages = $page->fpage(array(3,4,5,6,7,8));
        $data = M('zixun','DB_','DB_CONFIG1')->field('id,Question,SubmitTime,UserName,Province,City,BingQing_Menu_2,BingQing_Menu_1,HideName')->where("BingQing_Menu_2 LIKE '%|".$id."|%'")->order('id Desc')->limit($page->limit)->select();
        foreach ($data as $key => $value) {
            $data[$key]['UserName'] = hide_name($value['UserName']);
            $data[$key]['time'] = gm_time($value['SubmitTime']);
        }
        
        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'cat'           =>$cat,
            'data'          =>$data,
            'pages'         =>$pages,
        ));
        $id = I('get.id');
        $id = I('get.id','','intval');
        $this->display();
    }

    public function browse1(){
        $model = D('App/Base');
        //疾病分类
        $illnessData = M('Menu_1','BingQing_','DB_CONFIG1')->field('id,name,name2')->where('Display=0')->order('Id asc')->select();
        foreach ($illnessData as $key => $value) {
            $illnessData[$key]['info'] = M('Menu_2','BingQing_','DB_CONFIG1')->field('id,name,name2')->where("Display=0 and show_value Like '%|2|%' and Menu_1='".$value['id']."'")->order('Id asc')->limit(7)->select();
        }
        
        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);

        $this->assign(array(
            'illnessData'   =>$illnessData,
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,

        ));
        $this->display();
    }

    public function ask(){
        $model = D('App/Base');
        if(IS_POST){
            $data = I();
            //处理图片
            if(isset($_FILES['FileName']) && $_FILES['FileName']['error'] == 0)
            {
                $ret = uploadOne('FileName','Reportimg');
                if($ret['ok'] == 1)
                {
                    $data['Reportimg'] = $ret['images'][0];
                }
                else 
                {
                    $this->error('系统错误，请重试！');
                }
            }
            $new_id = M('zixun','DB_','DB_CONFIG1')->query("select max(id) from DB_ZiXun");
            $new_id = reset(array_values($new_id[0]));
            $data['id'] = $new_id + 1;
            $data['Title'] = I('post.Subject');
            $data['Info_Source'] = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
            $data['Info_IP'] = get_client_ip();
            $data['Views'] = rand(1000,20000);
            $data['SubmitTime'] = date('Y-m-d H:i:s.000', time());
            if(!$data['UserName']) $this->error('姓名不能为空！');
            if(!$data['Telephone']) $this->error('电话号码不能为空！');
            if(M('zixun','DB_','DB_CONFIG1')->data($data)->add()){
                $this->success('提交成功！');
                exit();
            }
        }
        //权威专家顾问团
        $doctor_team1 = M('Doctor')->field('id,name,other1,picture,introduction')->where("publish=1 and type=1 and (Id not in (1,2,3))")->order("orders desc,name_pinyin_index asc,id Desc")->limit(40)->select();
        //上海
        $doctor_str2 = M('center')->where('id=1')->getField('doctor_str');      
        $doctor_str2 = array_filter(explode('|', $doctor_str2));                                                                 
        $doctor_team2 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str2)))->order("orders desc,name_pinyin_index asc,id Desc")->limit(16)->select();
        //南京
        $doctor_str3 = M('center')->where('id=3')->getField('doctor_str');      
        $doctor_str3 = array_filter(explode('|', $doctor_str3));                                                                 
        $doctor_team3 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str3)))->order("orders desc,name_pinyin_index asc,id Desc")->limit(16)->select();
        //无锡
        $doctor_str4 = M('center')->where('id=4')->getField('doctor_str');      
        $doctor_str4 = array_filter(explode('|', $doctor_str4));                                                                 
        $doctor_team4 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str4)))->order("orders desc,name_pinyin_index asc,Id Desc")->limit(16)->select();
        //成都
        $doctor_str5 = M('center')->where('id=5')->getField('doctor_str');      
        $doctor_str5 = array_filter(explode('|', $doctor_str5));                                                                 
        $doctor_team5 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str5)))->order("orders desc,name_pinyin_index asc,Id Desc")->limit(16)->select();

        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'doctor_team1'  =>$doctor_team1,
            'doctor_team2'  =>$doctor_team2,
            'doctor_team3'  =>$doctor_team3,
            'doctor_team4'  =>$doctor_team4,
            'doctor_team5'  =>$doctor_team5,
        ));
        $this->display();
    }

    public function article(){
        $page_title = C("TITLE");
        $model = D('App/Base');
        $id = I('get.id',0,'intval');
        $data = M('article')->field('title,content,views,keywords,description')->find($id);
        
        //更多相关提问
        $more_ques = M('zixun','DB_','DB_CONFIG1')->query("select top 16 id,Question,SubmitTime,UserName,Province,City,BingQing_Menu_2,BingQing_Menu_1 from [DB_ZiXun] where Province <> '浙江' AND [publish]=1 and [centerid] IS NULL and ( [BingQing_Menu_1]<>'|' and [BingQing_Menu_2]<>'|' and [BingQing_Menu_2]<>'||' and [BingQing_Menu_1]<>'||' ) ORDER BY [id] Desc");
        
        //权威专家顾问团
        $doctor_team1 = M('Doctor')->field('id,name,other1,picture,introduction')->where("publish=1 and type=1 and (Id not in (1,2,3))")->order("orders desc,name_pinyin_index asc,id Desc")->limit(40)->select();
        //上海
        $doctor_str2 = M('center')->where('id=1')->getField('doctor_str');      
        $doctor_str2 = array_filter(explode('|', $doctor_str2));                                                                 
        $doctor_team2 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str2)))->order("orders desc,name_pinyin_index asc,id Desc")->limit(16)->select();
        //南京
        $doctor_str3 = M('center')->where('id=3')->getField('doctor_str');      
        $doctor_str3 = array_filter(explode('|', $doctor_str3));                                                                 
        $doctor_team3 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str3)))->order("orders desc,name_pinyin_index asc,id Desc")->limit(16)->select();
        //无锡
        $doctor_str4 = M('center')->where('id=4')->getField('doctor_str');      
        $doctor_str4 = array_filter(explode('|', $doctor_str4));                                                                 
        $doctor_team4 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str4)))->order("orders desc,name_pinyin_index asc,Id Desc")->limit(16)->select();
        //成都
        $doctor_str5 = M('center')->where('id=5')->getField('doctor_str');      
        $doctor_str5 = array_filter(explode('|', $doctor_str5));                                                                 
        $doctor_team5 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str5)))->order("orders desc,name_pinyin_index asc,Id Desc")->limit(16)->select();

        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'doctor_team1'  =>$doctor_team1,
            'doctor_team2'  =>$doctor_team2,
            'doctor_team3'  =>$doctor_team3,
            'doctor_team4'  =>$doctor_team4,
            'doctor_team5'  =>$doctor_team5,
            'data'          =>$data,
            'more_ques'     =>$more_ques,
        ));
        $page_title = array(
            'title'   => $data['title'] ? $data['title'] : $page_title['title'],
            'keyword' => $data['keywords'] ? $data['keywords'] : $page_title['keyword'],
            'desc'    => $data['description'] ? $data['description'] : $page_title['desc'],
        );
        $this->setPageInfo("{$page_title['title']}", "{$page_title['keyword']}", "{$page_title['desc']}", 1);
        $this->display();
    }

    public function question(){
        $model = D('App/Base');
        $id = I('get.id',0,'intval');
        $data = M('zixun','DB_','DB_CONFIG1')->field('UserName,marr,City,Info_IP,Province,Subject,Question,SubmitTime,Recom_Seque,BingQing_Menu_1,BingQing_Menu_2')->find($id);
        $data['SubmitTime'] = gm_time($data['SubmitTime']);
        $data['replay'] = M('Replay','DB_','DB_CONFIG1')->field('Content,ReplayTime')->where("BingLiId='$id'")->find();
        $data['replay']['ReplayTime'] = gm_time($data['replay']['ReplayTime']);
        $class_id_1 = reset(array_filter(explode('|', $data['BingQing_Menu_1'])));
        $illness1 = M('Menu_1','BingQing_','DB_CONFIG1')->field('id,name2')->where("Id='".$class_id_1."'")->find();
        $class_id_2 = reset(array_filter(explode('|', $data['BingQing_Menu_2'])));
        $illness2 = M('Menu_2','BingQing_','DB_CONFIG1')->field('id,name2')->where("Id='".$class_id_2."'")->find();
        //更多相关提问
        $more_ques = M('zixun','DB_','DB_CONFIG1')->query("select top 16 id,Question,SubmitTime,UserName,Province,City,BingQing_Menu_2,BingQing_Menu_1 from [DB_ZiXun] where Province <> '浙江' AND [publish]=1 and [centerid] IS NULL and ( [BingQing_Menu_1]<>'|' and [BingQing_Menu_2]<>'|' and [BingQing_Menu_2]<>'||' and [BingQing_Menu_1]<>'||' ) and ([BingQing_Menu_2] Like '%|".$class_id_2."|%') ORDER BY [id] Desc");
        
        //权威专家顾问团
        $doctor_team1 = M('Doctor')->field('id,name,other1,picture,introduction')->where("publish=1 and type=1 and (Id not in (1,2,3))")->order("orders desc,name_pinyin_index asc,id Desc")->limit(40)->select();
        //上海
        $doctor_str2 = M('center')->where('id=1')->getField('doctor_str');      
        $doctor_str2 = array_filter(explode('|', $doctor_str2));                                                                 
        $doctor_team2 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str2)))->order("orders desc,name_pinyin_index asc,id Desc")->limit(16)->select();
        //南京
        $doctor_str3 = M('center')->where('id=3')->getField('doctor_str');      
        $doctor_str3 = array_filter(explode('|', $doctor_str3));                                                                 
        $doctor_team3 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str3)))->order("orders desc,name_pinyin_index asc,id Desc")->limit(16)->select();
        //无锡
        $doctor_str4 = M('center')->where('id=4')->getField('doctor_str');      
        $doctor_str4 = array_filter(explode('|', $doctor_str4));                                                                 
        $doctor_team4 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str4)))->order("orders desc,name_pinyin_index asc,Id Desc")->limit(16)->select();
        //成都
        $doctor_str5 = M('center')->where('id=5')->getField('doctor_str');      
        $doctor_str5 = array_filter(explode('|', $doctor_str5));                                                                 
        $doctor_team5 = M('Doctor')->field('id,name,other1,picture,introduction')->where(array('publish'=>array('eq',1),'type'=>array('eq',1),'id'=>array('in',$doctor_str5)))->order("orders desc,name_pinyin_index asc,Id Desc")->limit(16)->select();

        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'doctor_team1'  =>$doctor_team1,
            'doctor_team2'  =>$doctor_team2,
            'doctor_team3'  =>$doctor_team3,
            'doctor_team4'  =>$doctor_team4,
            'doctor_team5'  =>$doctor_team5,
            'data'          =>$data,
            'illness1'      =>$illness1,
            'illness2'      =>$illness2,
            'more_ques'     =>$more_ques,
        ));
        $page_title['title'] = $data['Subject'];
        $this->setPageInfo("{$page_title['title']}", "{$page_title['keyword']}", "{$page_title['desc']}", 1);
        $this->display();
    }

    public function newnew(){
        $model = D('App/Base');
        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
        ));
        $this->display();
    }

    public function hot(){
        $model = D('App/Base');
        //热点咨询问题
        $count = M('zixun','DB_','DB_CONFIG1')->where("pudong=0 and hangzhou=0 and [Publish]=1 and ([centerid] is null) and [Recommend]=1 and ( [BingQing_Menu_1]<>'|' and [BingQing_Menu_2]<>'|' and [BingQing_Menu_2]<>'||' and [BingQing_Menu_1]<>'||' )")->count();
        $page = new \Tool\Page($count,35);
        // 配置翻页的样式
        $pages = $page->fpage(array(3,4,5,6,7,8));
        $redian = M('zixun','DB_','DB_CONFIG1')->field('id,Question,SubmitTime,UserName,Province,City,BingQing_Menu_2,BingQing_Menu_1,HideName')->where("pudong=0 and hangzhou=0 and [Publish]=1 and ([centerid] is null) and [Recommend]=1 and ( [BingQing_Menu_1]<>'|' and [BingQing_Menu_2]<>'|' and [BingQing_Menu_2]<>'||' and [BingQing_Menu_1]<>'||' )")->order('id Desc')->limit($page->limit)->select();
        foreach ($redian as $key => $value) {
            $time = json_decode( json_encode($value['SubmitTime']), true);
            $redian[$key]['time'] = substr($time['date'], 0,10);
        }
        
        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'redian'        =>$redian,
            'pages'         =>$pages,
        ));
        $this->display();
    }

    public function focus(){
        $model = D('App/Base');
        //热点咨询问题
        $count = M('Article a')->where("a.State=1 and a.Publish=1 and (a.Class in (384))")->count();
        $page = new \Tool\Page($count,35);
        // 配置翻页的样式
        $pages = $page->fpage(array(3,4,5,6,7,8));
        $changjian = M('Article a')->field('a.id,a.class,a.title,a.ArticleTime,a.views')->where("a.State=1 and a.Publish=1 and (a.Class in (384))")->order('a.ArticleTime desc,a.id desc')->limit($page->limit)->select();

        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'changjian'        =>$changjian,
            'pages'         =>$pages,
        ));
        $this->display();
    }

    public function video(){
        $model = D('App/Base');
        //热点咨询问题
        $count = M('Article a')->where("a.Class in (300,299,298) and a.state=1 and a.Publish=1 and (Thumbnails IS NOT NULL) and (Thumbnails <> '')")->count();
        $page = new \Tool\Page($count,30);
        // 配置翻页的样式
        $pages = $page->fpage(array(3,4,5,6,7,8));
        $video = M('Article a')->field('a.id,a.class,a.title,a.ArticleTime,a.views')->where("a.Class in (300,299,298) and a.state=1 and a.Publish=1 and (Thumbnails IS NOT NULL) and (Thumbnails <> '')")->order('a.id desc')->limit($page->limit)->select();

        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'video'        =>$video,
            'pages'         =>$pages,
        ));
        $this->display();
    }

    public function phone(){
        $model = D('App/Base');
        //电话实录列表
        $count = M('Article a')->where("a.Class in (382) and a.state=1 and a.Publish=1")->count();
        $page = new \Tool\Page($count,30);
        // 配置翻页的样式
        $pages = $page->fpage(array(3,4,5,6,7,8));
        $phone = M('Article a')->field('a.id,a.class,a.title,a.ArticleTime,a.views')->where("a.Class in (382) and a.state=1 and a.Publish=1")->order('a.id desc')->limit($page->limit)->select();

        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'phone'         =>$phone,
            'pages'         =>$pages,
        ));
        $this->display();
    }

    public function text(){
        $model = D('App/Base');
        //文字实录列表
        $count = M('Article a')->where("a.Class in (301) and a.state=1 and a.Publish=1")->count();
        $page = new \Tool\Page($count,30);
        // 配置翻页的样式
        $pages = $page->fpage(array(3,4,5,6,7,8));
        $text = M('Article a')->field('a.id,a.class,a.title,a.ArticleTime,a.views')->where("a.Class in (301) and a.state=1 and a.Publish=1")->order('a.id desc')->limit($page->limit)->select();

        //视频-电话实录-文字实录
        $video_phone1 = $model->get_article(array('a.Class'=>array('in','300,299,298,381'),'a.state'=>array('eq',1),'a.publish'=>array('eq',1),'a.Thumbnails'=>array('neq','')),'',1,'',array('length'=>45));
        $video_phone2 = $model->get_article(array('a.Class'=>array('in','301,382'),'a.state'=>array('eq',1)),'',8);
        $this->assign(array(
            'video_phone1'  =>$video_phone1[0],
            'video_phone2'  =>$video_phone2,
            'text'          =>$text,
            'pages'         =>$pages,
        ));
        $this->display();
    }

    /*************function*************/
    public function cat_list($id){
        $illness = M('Menu_2','BingQing_','DB_CONFIG1')->field('id,name2,menu_1')->where('Id='.$id)->find();
        $parent_info = M('Menu_1','BingQing_','DB_CONFIG1')->field('id,name2')->where('Id='.$illness['menu_1'])->find();
        $info = M('Menu_2','BingQing_','DB_CONFIG1')->field('id,name2')->where('Menu_1='.$parent_info['id'])->select();
        $arr = array_merge($illness,array('parent'=>$parent_info, 'info'=>$info));
        return $arr;
    }
}